package com.itboye.ihomebank.adapter;

import java.text.SimpleDateFormat;
import java.util.List;

import android.content.Context;

import com.itboye.ihomebank.R;
import com.itboye.ihomebank.base.SystemMessBean.Sysitem;
import com.itboye.ihomebank.support.commonadapter.MutiplyCommonAdapter;
import com.itboye.ihomebank.support.commonadapter.ViewHolder;

/**
 * 系统消息
 * 
 */
public class SystemMessageAdapter extends MutiplyCommonAdapter<Sysitem> {
	int position;
	List<Sysitem> datas;
	private int type;

	public SystemMessageAdapter(Context context, List<Sysitem> datas,
			int... layoutId) {
		super(context, datas, layoutId);
		this.datas = datas;
	}

	@Override
	public int getItemViewType(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public void getItemPosition(int position) {
		this.position = position;

	}

	@Override
	public void convert(ViewHolder holder, Sysitem t, int type, int position) {
		holder.setText(R.id.sys_title, t.getTitle());
		holder.setText(R.id.sys_content, t.getContent());
		holder.setText(R.id.sys_time, new SimpleDateFormat("yyyy-MM-dd HH:ss")
				.format(Long.parseLong(t.getCreate_time()) * 1000));
		if (this.type == 1) {
			holder.setBackgroundRes(R.id.icon, R.drawable.xitongxiaoxi);
		} else if (this.type == 2) {
			holder.setBackgroundRes(R.id.icon, R.drawable.default_head);
		} else if (this.type == 3) {
			holder.setBackgroundRes(R.id.icon, R.drawable.default_head);
		} else if (this.type == 4) {
			holder.setBackgroundRes(R.id.icon, R.drawable.key);
		}
	}

	public void setType(int type) {
		this.type = type;

	}

}
